<?php

include_once 'utilities/includes.php';

$Fname = $_POST["Fname"];
$Lname = $_POST["Lname"];
if (!isset($_POST['NS_PROTOCOL'])) { // if page is not submitted to itself echo the form
?>
<html>
<head>
<title>Personal INFO</title>
</head>
<body>
<form method="POST" action="<?php echo "http://".$_SERVER['SERVER_NAME'].$_SERVER['PHP_SELF'];?>">
First Name:<input type="text" size="12" maxlength="12" name="Fname" /><br />
Last Name:<input type="text" size="12" maxlength="36" name="Lname" /><br />
<textarea rows="5" cols="20" name="quote" wrap="physical">Enter your favorite quote!</textarea><br />
<input type="submit" value="submit" name="submit">
</form>
<?
} else {
    
    file_put_contents("/tmp/bert.txt", util::toString($_POST));
    
     switch ($_POST['NS_PROTOCOL']) {
         case "image":
             $files = file::folder_files("../incoming/","/",true);
             $toSend = array();
             foreach ($files as $file) {
                 $toSend[] = urlencode("http://sal-cairns.jcu.edu.au/nordic-sauna".$file);
             }
             
             echo join("&",  $toSend);
             break;

         case "text":
                echo "http://sal-cairns.jcu.edu.au/nordic-sauna/content/fred.txt";
             break;

         case "upload":
             echo util::toString($_POST);
             file_put_contents("/tmp/fred.txt", util::toString($_POST));
             
             break;
         
         default:
             break;
     }
    
    
    
    
    // echo "Hello, ".$Fname." ".$Lname." and this is ".$_POST['un'];
    
    
    
}
?>